package Thread;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Semaphore;

public class JUC {
    public static void main(String[] args) throws InterruptedException, BrokenBarrierException {
        //门闩
        CountDownLatch countDownLatch=new CountDownLatch(3);
        countDownLatch.countDown();//-1
        countDownLatch.await();//到0能执行
        //栅栏
        //重置数量 循环往复 到0自动为2
        CyclicBarrier cyclicBarrier=new CyclicBarrier(2);
        cyclicBarrier.await();
        //递增
        Semaphore semaphore=new Semaphore(0);
        semaphore.release();//+1
        semaphore.acquire(2);//到二了能运行

    }
}



